package com.goldfish666.remote_control.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum FunctionEnum {

    /**
     * 电源开关
     */
    powerSwitch(0, "powerSwitch"),

    /**
     * 主页
     */
    homePage(1, "homePage"),

    /**
     * U
     */
    U(2, "U"),

    /**
     * 设置
     */
    settings(3, "settings"),

    /**
     * up
     */
    up(4, "up"),

    /**
     * down
     */
    down(5, "down"),

    /**
     * left
     */
    left(6, "left"),

    /**
     * right
     */
    right(7, "right"),

    /**
     * ok
     */
    ok(8, "ok"),

    /**
     * refresh
     */
    refresh(9, "refresh"),

    /**
     * timer
     */
    timer(10, "timer"),

    /**
     * stop
     */
    stop(11, "stop"),

    /**
     * increase
     */
    increase(12, "increase"),

    /**
     * decrease
     */
    decrease(13, "decrease"),

    /**
     * diamond
     */
    diamond(14, "diamond");

    private int value;

    private String desc;

    FunctionEnum(int option, String desc) {
        this.value = option;
        this.desc = desc;
    }

    @JsonCreator
    public static FunctionEnum fromValue(@JsonProperty("value") final int option) {
        for (FunctionEnum e : FunctionEnum.values()) {
            if (e.value == option) {
                return e;
            }
        }
        return null;
    }

    public int getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }
}
